<?php

namespace app\rider\controller;

use app\admin\model\AdminModel;
use app\rider\services\AlipayService;
use app\rider\services\RiderService;
use think\facade\Validate;

class Auth extends \app\BaseController
{
    protected $middleware=['CheckRiderTokenMiddleware'=>['only'=>'logout']];

    /**
     * 登录
     * @return void
     * @throws \Psr\SimpleCache\InvalidArgumentException
     */
    public function login(){
        $p=$this->request->post();
        $rule=[
            'platform'=>'require|in:zfb'
        ];
        $validate=Validate::rule($rule);
        if(!$validate->check($p)){
            api_return(500,'something wrong,try again later.');
        }
        switch ($p['platform']){
            case 'zfb':
                AlipayService::login($p);
                break;
            default:
                break;
        }
    }

    /**
     * 登出
     * @return void
     */
    public function logout(){
        api_return(200);
    }

    /**
     * 绑定
     * @return void
     */
    public  function bind(){
        $p=$this->request->post();
        RiderService::bind($p);
    }

    /**
     * 解密
     * @return void
     */
    public function decrypt(){

        $p=$this->request->post();
        $result=AlipayService::decrypt($p);
        api_return(200,'',$result);
    }

}
